I 've created a customer control menulink. CS in Silverlight 2beta2, and the code like this:
Public class menulink: Control
{
Public menulink ()
{
Defaultstylekey = typeof (menulink );
This. Loaded + = new routedeventhandler (menulink_loaded );
}
Void menulink_loaded (Object sender, routedeventargs E)
{
Share the method for jquery to take the child node and the current node property values.To take a child node:$ (". Menulink a"). each (function () {var id=this.id;}); Www.jbxue.comTake the current node:$ (". Menulink"). each (function () {var id=this.id;});
(MENUID);var links=menuid.getelementsbytagname ("a");for (var i=0; ivar menulink=links[i].href;var currentlink=window.location.href;if (Currentlink.indexof (menulink)!=-1) {Links[i].classname=classcur;}}}
Parameter description:1.MENUID: The ID of the link group;2.classcur: The style class name when highlighted.Call Method:Window.onload=function Highthis () {Highurl ("Youid", "Youhighclass");}The first
Jquery method for getting the attribute values of subnodes and current nodes, jquery attribute values
This section describes how to obtain the attribute values of subnodes and current nodes by jquery.
Child Nodes:
$ (". Menulink a"). each (function () {var id = this. id ;});
Take the current node:
$ (". Menulink"). each (function () {var id = this. id ;});
For jQuery problems, how can I obtain the i
Jquery method for obtaining the attribute values of subnodes and current nodes
This section describes how to obtain the attribute values of subnodes and current nodes by jquery.
1
2
3
4
Child Nodes:
1
$ (". Menulink a"). each (function (){
2
Var id = this. id;
3
});
Jquery obtains the attributes of the subnode and the current node. The jquery Attribute Value
Child Nodes:
$ (". Menulink a"). each (function () {var id = this. id ;});
Take the current node:
$ (". Menulink"). each (function () {var id = this. id ;});
How does jQuery obtain the previous node of the current node? $ (This) prov ()?
Yes $ (this). prev (), not provFor jQuery problems, how can I obtain t
elements by passing in the corresponding class parameters, although IE8 the following version does not support this method. A high performance practice is to cache jquery objects through variables. For example:
Js:
Bad way:
//$ (' #pancakes li '). EQ (0). Remove ();
$ (' #pancakes li '). EQ (1). Remove ();
$ (' #pancakes li '). EQ (2). Remove ();
------------------------------------
//Recommended way:
var pancakes = $ (' #pancakes Li ');
Pancakes.eq (0). Remove ();
Pancake
A method of sharing the values of the jquery node and the current node attribute.
1
2
3
4
To take child nodes:
1
$ (". Menulink a"). each (function () {
2
var id=this.id;
3
});
Take the current node:
1
$ (". Menu
(MENUID)) return false;
if (!document.getelementsbytagname) return false;
var Menuid=document.getelementbyid (MENUID);
var links=menuid.getelementsbytagname ("a");
for (var i=0; ivar menulink=links[i].href;
var currentlink=window.location.href;
if (Currentlink.indexof (menulink)!=-1) {
Links[i].classname=classcur;
}
}
}
Parameter description:
1.MENUID: The ID of the link group;
Step 1: materialized X-Menu classUsage:Var --->Step 2: Create a menu project ---Usage:Type: 0 indicates the menu title, 1 indicates the tree menu sub-project, and 2 indicates the horizontal Menu Sub-project.Html code: Html code displayed on the menuLink URL: Needless to say, URL or Javascript scriptTarget: empty by default, which is not opened on this page; "_ blank" indicates opening on a new pageFor example:CoolMenu2.insertmenu ("2", " Sina", "http:
duplicate functions, define only once
If you're looking for more high-performance code, you have to be careful when you set up the event listener, it's a good idea to define the function once and pass its name as an event handler.
$ (document). Ready (function () {
function ShowMenu () {
alert (' showing menu! ');
Doing something complex here
}
$ (' #menuButton '). Click (showmenu);
$ (' #menuLink '). Click (showmenu);
21. Treat
Code encapsulatedThank you for your support!For more information, see the menu of some Flash sites,I used javascript to simulate one, and the effect was Cool.Write a simple instruction:Step 1: materialized X-Menu classUsage:Var Step 2: Create a menu project ---Usage:Type: 0 indicates the menu title, 1 indicates the tree menu sub-project, and 2 indicates the horizontal Menu Sub-project.Html code: Html code displayed on the menuLink URL: Needless to say
Step 1: materialized X-menu classUsage:VaR --->Step 2: Create a menu project ---Usage:Type: 0 indicates the menu title, 1 indicates the tree menu sub-project, and 2 indicates the horizontal Menu Sub-project.HTML code: HTML code displayed on the menuLink URL: Needless to say, URL or Javascript scriptTarget: empty by default, which is not opened on this page; "_ blank" indicates opening on a new pageFor example:Coolmenu2.insertmenu ("2", " Sina", "http:
Document directory
HTML tags and JavaScript tutorial
HTML tags and JavaScript tutorial
A cool JS menu
Step 1: materialized X-menu classUsage:VaR --->Step 2: Create a menu project ---Usage:Type: 0 indicates the menu title, 1 indicates the tree menu sub-project, and 2 indicates the horizontal Menu Sub-project.HTML code: HTML code displayed on the menuLink URL: Needless to say, URL or Javascript scriptTarget: empty by default, which is not opened
Contact Us
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.